<?php
function CreateMenu(&$menuBar, $menuList)
{
	
	foreach ($menuList as $topName => $subList) 
	{
		$topMenu = new GtkMenuItem($topName);//创建一个顶级目录
		$menuSub = new GtkMenu();//创建子目录控件
		if(is_array($subList))
		{
			foreach ($subList as $subName => $func)
			{
				if($func == '-')
				{
					$menuSub->append(new GtkSeparatorMenuItem());
				}else{
					if(is_array($subName))
					{
						$sub = new GtkMenuItem($subName[0]);//创建一个子目录
						$sub ->set_accel_path($subName[1]);
					}else{
						$sub = new GtkMenuItem($subName);
					}
					if(!empty($func))
					{
						$sub->connect_simple('activate', $func);
					}
					$menuSub->append($sub);//将子目录添加到子目录控件上
				}
			}
		}
		$topMenu->set_submenu($menuSub);//将子目录控件添加到顶级目录上
		$menuBar->add($topMenu);
	}
	return $menuBar;
}
function CreateTool(& $toolBar, $toolList)
{
	foreach ($toolList as  $func => $stock)
	{
		if($stock == '|')
		{
			$toolButton = new GtkSeparatorToolItem();
		}else{
			$toolButton = new GtkToolButton();
			$toolButton->set_stock_id($stock);
			$toolButton->connect_simple('clicked', $func);
		}
		$toolBar->add($toolButton);
	}
	return $toolBar;
}
function mainQuit()
{
	Gtk::main_quit();
}
function printCode()
{
	
}
function addFtp()
{
	
}
function histoy()
{
	
}
function newFile()
{
	return CreateNewFile($GLOBALS['mainWindow']->right,$GLOBALS['mainWindow']->fileNum);
}
function openFile()
{
	$open = new GtkFileChooserDialog();
	return $open;
}
function closeFile()
{
	
}
function closeAll()
{
	
}
function save()
{
	
}
function saveAs()
{
	
}
function saveAll()
{
	
}
function cut()
{
	
}
function copyWord()
{
	
}
function paste()
{
	
}
function undo()
{
	
}
function redo()
{
	
}
function find()
{
	
}
function findAndReplace()
{
	
}
function preferences()
{
	
}
function CreateNewFile(& $noteBook, & $fileNum)
{
	$fileNum ++;
	$defaultScrolled = new GtkScrolledWindow();
	$text_view = new GtkTextView();
    $defaultScrolled->add($text_view);
	$noteBook ->append_page($defaultScrolled, new GtkLabel("Noname{$fileNum}.php"));
	return $noteBook;
}